package blackitheima1.FileWrite;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

//键盘键盘录入,并储存到本地文件
public class MyFileWrite1 {
    public static void main(String[] args) throws IOException {
        //创建键盘录入对象
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入用户名:");
        String userName = sc.next();
        System.out.println("请输入密码:");
        String password = sc.next();
        //创建字符输出流 写数据 带换行
        FileWriter fw=new FileWriter("day12\\ccc");
        //写入数据
        fw.write(userName);
        //换行
        fw.write("\r\n");
        fw.write(password);
        //刷新流
        fw.flush();
        //释放资源
        fw.close();
    }
}
